package com.example.finalwork.entity.dao;

import com.example.finalwork.entity.User;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

public class UserDao {
    @Length(max = 10, message = "用户ID长度不能超过10个字符")
    private String id; // 对应数据库的 user_id

    @Length(max = 50, message = "用户名长度不能超过50个字符")
    private String name; // 对应数据库的 user_name

    @NotBlank(message = "密码不能为空")
    @Length(min = 6, max = 20, message = "密码长度必须在6到20个字符之间")
    private String password; // 对应数据库的 user_password

    @NotBlank(message = "邮箱不能为空")
    @Email(message = "邮箱格式不正确")
    @Length(max = 50, message = "邮箱长度不能超过50个字符")
    private String email; // 对应数据库的 email

    @NotBlank(message = "手机号不能为空")
    @Length(min = 11, max = 11, message = "手机号必须是11位数字")
    private String phone; // 对应数据库的 phone

    @NotBlank(message = "昵称不能为空")
    @Length(max = 50, message = "昵称长度不能超过50个字符")
    private String nickname; // 对应数据库的 nickname
    @NotNull(message = "性别不能为空")
    private User.Gender gender; // 对应数据库的 gender (枚举类型)
    @NotNull(message = "年龄不能为空")
    private Integer age; // 对应数据库的 age

    // 默认构造器
    public UserDao() {
        this.age = 18; // 默认年龄
        this.gender = User.Gender.未知; // 默认性别
    }
    // 构造器
    // 构造器
    public UserDao(String id, String name, String password, String email, String phone, String nickname, User.Gender gender, Integer age) {
        this.id = id;
        this.name = name;
        this.password = password;
        this.email = email;
        this.phone = phone;
        this.nickname = nickname;
        this.gender = gender;
        this.age = age;
    }


    // Getter 和 Setter
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public User.Gender getGender() {
        return gender;
    }

    public void setGender(User.Gender gender) {
        this.gender = gender;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "UserDao{" +
                "name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                ", nickname='" + nickname + '\'' +
                ", gender=" + gender +
                ", age=" + age +
                '}';
    }
}
